home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / exec / istrue.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  1.0 KB  |  48 lines

  1. /*
  2. \funcref{istrue}{void istrue ()}
  3.     {}
  4.     {0: the last pushed variable yields `false'; otherwise: the last pushed
  5.      variable yields `true'}
  6.     {pop(), discard()}
  7.     {fun\_jmp\_true(), fun\_jmp\_false()}
  8.     {istrue.c}
  9.     {
  10.  
  11.         This function pops the last pushed variable and determines if that
  12.     variable should yield true. If the variable is of type {\em e\_int},
  13.     then the integer representation is returned. If the variable is of
  14.     type {\em e\_str}, then the first character in the string (this may
  15.     be a zero-byte) is returned. If the variable is of type {\em
  16.     e\_list}, the list size is returned.
  17.  
  18.         The popped variable is discarded.
  19.  
  20.     }
  21. */
  22.  
  23. #include "icm-exec.h"
  24.  
  25. int istrue ()
  26. {
  27.     VAR_
  28.         tmp;
  29.     register int
  30.         ret;
  31.  
  32.     tmp = pop ();
  33.     if (tmp.type & e_int)
  34.         ret = tmp.vu.intval;
  35.     else if (tmp.type & e_str)
  36.     {
  37.         if (tmp.vu.i->ls.str)
  38.             ret = (int) *(tmp.vu.i->ls.str);
  39.     else
  40.         ret = 0;
  41.     }        
  42.     else
  43.         ret = tmp.vu.i->ls.list.size;
  44.  
  45.     discard (tmp);
  46.     return (ret);
  47. }
  48.